<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		
		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		
		<div id="app">
			<h1>使用组件</h1>
			计数器:<counter></counter><br />
			计数器:<counter></counter><br />
			计数器:<counter></counter><br />
			计数器:<counter></counter><br />
			计数器:<counter></counter><br />
			<wrapper></wrapper>
		</div>
		
		<script>			
			
			var app = Vue.createApp({
				data(){
					return 
					{
						
						} 
				}
			});
			app.component('counter',{
				//data
				data(){
					return{
						count:0
					}
				},
				//template
				template:'<button @click="count++">{{count}}</button>'
				//methods
			});
			app.component('wrapper',{
				data(){
					return{
					msg:'我是wrapper，是一个自定义组件！',
					num:0,
					}
				},
			
				template:'<div>{{msg}}<br>{{num}}<button @click="add">+</button></div>',			
				methods:{
					add(){
						this.num++;
					}
				},
			})
			var vm = app.mount("#app")
		</script>
	</body>
</html>
